package cn.wolfcode.crm.shrio.freeMarker;

import com.jagregory.shiro.freemarker.ShiroTags;
import freemarker.template.TemplateException;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

import java.io.IOException;

/**
 * freemarker的shiro标签 要生效
 *
 * 定义一个配置类,继承FreeMarkerConfigurer(拷贝)
 * 并且 用该类 ShiroTagFreeMarkerConfigurer 的全限定名 配置在mvc中freemarker的bean中的class里面
 */
public class ShiroTagFreeMarkerConfigurer extends FreeMarkerConfigurer {
    @Override
    public void afterPropertiesSet() throws IOException, TemplateException {
        super.afterPropertiesSet();
        this.getConfiguration().setSharedVariable("shiro", new ShiroTags());
    }
}
